package com.youtills.core.config;

/**
 * Created by IntelliJ IDEA.
 * User: ravi
 * Date: 8/26/12
 * Time: 12:12 AM
 * To change this template use File | Settings | File Templates.
 */
public class Config implements IConfig {

    private final String key;
    private final String defaultValue;

    public Config(String key) {
        this(key, null);
    }
    public Config(String key, String defaultValue) {
        this.key = key;
        this.defaultValue = defaultValue;
    }

    public String getStringValue(){
        return getConfigValue().getValue();
    }


    public IConfigValue getConfigValue() {
        IConfigValue configValue = ConfigurationLoader.getConfigValue(key);
        if(configValue == null){
            configValue = new ConfigValue(defaultValue, "Default Value");
        }
        return configValue;
    }


    public String getKey() {
        return key;
    }
}
